using CfgTable;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_MonthCardTemplate : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_MonthCardTemplate
        {
            #region ObjectBinding Generate
            public UnityEngine.GameObject left { protected set; get; }
            public UnityEngine.GameObject right { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.GameObject>("left", out var __tbv0);
                this.left = __tbv0;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("right", out var __tbv1);
                this.right = __tbv1;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify



        #region fields

        UIN_MonthCardCell monthCardNormal;
        UIN_MonthCardCell monthCardBig;

        #endregion fields

        #region properties

        protected UIB_UIN_MonthCardTemplate ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;

        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_MonthCardTemplate();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
            this.monthCardNormal = this.InitChildNode<UIN_MonthCardCell>(this.ui.left);
            this.monthCardBig = this.InitChildNode<UIN_MonthCardCell>(this.ui.right);
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {

        }

        #region methonds
        public void Show(CfgMallType cfgMallType)
        {
            if (!TableCenter.mallItem.MallItemMap.TryGetValue(cfgMallType.Id, out var rMallItemList))
            {
                return;
            }
            var cfgmallItem1 = TableCenter.mallItem.Get(rMallItemList[0]);
            var cfgmallItem2 = TableCenter.mallItem.Get(rMallItemList[1]);
            this.monthCardNormal.Show(cfgmallItem1);
            this.monthCardBig.Show(cfgmallItem2);

            this.Show();
        }


        #endregion methonds
    }
}
